package com.briup.day13;

public class Test_Cache {
    public static void main(String[] args) {
        String s1 = "a";
        String s2 = "b";
        String s3 = "a+b";
        String s4 = "ab";
        System.out.println(s3==s4);
        System.out.println(s3.equals(s4));
        System.out.println("----------------------");
        String s5 = s1 + s2;
        System.out.println(s4.equals(s5)); // true
        System.out.println(s4 == s5); // false
        System.out.println("-------------");
        String s6 = (s1 + s2).intern();
        System.out.println(s4.equals(s6)); // true
        System.out.println(s4 == s6); // true

    }
    public static void main01(String[] args) {
        String s1 = "Hello";
        String s2 = "Hello";
        System.out.println(s1==s2);
        String s3 = new String("Hello");
        String s4 = new String("Hello");
        System.out.println(s3==s4);
        System.out.println(s1==s3);
        String s5 = new String("World");
        String s6 = new String("World").intern();
        String s7 = "World";
        System.out.println(s5==s6);
        System.out.println(s6==s7);
    }
}
